let mysql=require('mysql');
let contion=mysql.createConnection({
    host:'127.0.0.1',
    user:'root',
    password:'root',
    database:'mydb'
})
let a=getNum(1,3);
let b=3;
contion.connect();
let sql="select * from user limit ?,?";
console.log(sql)
contion.query(sql,[a,b],(err,data)=>{
    console.log(err,data);
})
let sql1="SELECT u_sex,COUNT(u_sex) as 人数 ,(select count(u_sex) from user) FROM `user` GROUP BY u_sex";
contion.query(sql1,(err,data)=>{
    console.log(err,data);
})
let sql2="SELECT distinct (SELECT COUNT(u_sex) as 小于18 FROM `user` WHERE u_age <18) as 小于18 ,(SELECT COUNT(u_sex)  as 十八到四十五 FROM `user` WHERE u_age  BETWEEN 18 and 45)as 十八到四十五,(SELECT COUNT(u_sex) as 大于45 FROM `user` WHERE u_age >45)as 大于45 FROM `user`"
contion.query(sql2,(err,data)=>{
    console.log(err,data);
})
















contion.end();
function getNum(page,num){
    return (page-1)*num;
}